package edu.fmi.st.epf.types.skill.ui.provider;

import java.util.Collection;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.epf.uma.CustomCategory;
import org.eclipse.epf.uma.UmaPackage;
import org.eclipse.swt.graphics.Image;

import edu.fmi.st.epf.types.skill.common.util.SkillHelper;
import edu.fmi.st.epf.types.skill.ui.SkillActivator;
import eu.tanov.epf.itemprovider.extension.CustomItemProvider;

public class SkillGroupItemProvider extends BaseSkillsItemProvider implements
		CustomItemProvider {

	public SkillGroupItemProvider() {
		this(null);
	}

	public SkillGroupItemProvider(AdapterFactory adapterFactory) {
		super(adapterFactory);
	}

	@SuppressWarnings("unchecked")
	@Override
	public void collectNewChildDescriptors(
			@SuppressWarnings("rawtypes") Collection newChildDescriptors,
			Object object) {
		// newChildDescriptors.clear();
		newChildDescriptors.add(createChildParameter(
				UmaPackage.eINSTANCE.getContentPackage_ContentElements(),
				SkillHelper.makeCategory(SkillHelper.MAKE_SKILL_TEXT)));
		newChildDescriptors.add(createChildParameter(
				UmaPackage.eINSTANCE.getContentPackage_ContentElements(),
				SkillHelper.makeCategory(SkillHelper.MAKE_GROUP_TEXT)));
	}

	public Object getCreateChildImage(Object owner, Object feature,
			Object child, Collection selection) {
		if (child instanceof CustomCategory) {
			return SkillActivator.getDefault().getImage("full/obj/Skill"); //$NON-NLS-1$
		}
		throw new IllegalStateException("Unknown child type for Skill: "
				+ child);
	}

	public boolean isWrappingNeeded(Object object) {
		return false;
	}

	public boolean matches(Object object) {
		return SkillHelper.isSkillGroup(object);
	}

	public static Image getSkillGroupImage() {
		return SkillActivator.getDefault().getImage("full/obj/Skill"); //$NON-NLS-1$
	}

}
